package com.raos.lottery.redis.constants;

/**
 * Redis Key 管理工具
 *
 * @author raos
 * @emil 991207823@qq.com
 * @date 2021/7/21 23:01
 */
public class RedisKeyManager {

    private RedisKeyManager() {
    }

    /**
     * 正在抽奖的key
     *
     * @param accountIp 账户ip
     * @return
     */
    public static String getDrawingRedisKey(String accountIp) {
        return LotteryConstants.DRAWING + ":" + accountIp;
    }

    /**
     * 获取抽奖活动的key
     *
     * @param id 抽奖活动id
     * @return
     */
    public static String getLotteryRedisKey(Integer id) {
        return LotteryConstants.LOTTERY + ":" + id;
    }

    /**
     * 获取指定活动下的所有奖品数据的 key
     *
     * @param lotteryId 抽奖活动id
     * @return
     */
    public static String getLotteryPrizeRedisKey(Integer lotteryId) {
        return LotteryConstants.LOTTERY_PRIZE + ":" + lotteryId;
    }

    /**
     * 获取指定活动下的某奖品数据的 key
     * @param lotteryId 抽奖活动id
     * @param prizeId 奖品id
     * @return
     */
    public static String getLotteryPrizeRedisKey(Integer lotteryId, Integer prizeId) {
        return LotteryConstants.LOTTERY_PRIZE + ":" + lotteryId + ":" + prizeId;
    }

    /**
     * 获取指定活动默认奖品数据的key
     * @param lotteryId 抽奖活动id
     * @return
     */
    public static String getDefaultLotteryPrizeRedisKey(Integer lotteryId) {
        return LotteryConstants.DEFAULT_LOTTERY_PRIZE + ":" + lotteryId;
    }

    /**
     * 获取指定抽奖项的key
     * @param lotteryId 抽奖活动id
     * @return
     */
    public static String getLotteryItemRedisKey(Integer lotteryId) {
        return LotteryConstants.LOTTERY_ITEM + ":" + lotteryId;
    }

    /**
     * 获取默认抽奖项的key
     * @param lotteryId 抽奖活动id
     * @return
     */
    public static String getDefaultLotteryItemRedisKey(Integer lotteryId) {
        return LotteryConstants.DEFAULT_LOTTERY_ITEM + ":" + lotteryId;
    }

}
